{% load staticfiles %}
<!--atsystem-->
<!DOCTYPE html>
<html>
    
    <head>
        <title>Exec Command</title>
        <!-- Bootstrap -->
        <link href="{% static 'bootstrap/css/bootstrap.min.css' %}" rel="stylesheet" media="screen">
        <link href="{% static 'bootstrap/css/bootstrap-responsive.min.css' %}" rel="stylesheet" media="screen">
        <link href="{% static 'assets/styles.css' %}" rel="stylesheet" media="screen">
        <link href="{% static 'assets/DT_bootstrap.css' %}" rel="stylesheet" media="screen">
        <script src="{% static 'vendors/modernizr-2.6.2-respond-1.1.0.min.js' %}"></script>
        <script src="{% static 'artDialog/lib/jquery-1.10.2.js'%}"></script>
        <link href="{% static 'artDialog/css/ui-dialog.css'%}" rel="stylesheet">
        <script src="{% static 'artDialog/dist/dialog-min.js'%}"></script>

    </head>
    
    <body>
 <!--               <div class="span9" id="content">-->
                        <!-- block -->
                        <div class="block">
                            <div class="navbar navbar-inner block-header">
                                <div class="muted pull-left">Exec Command</div>
                            </div>
                            <div class="block-content collapse in">
            <!--                    <div class="span12">
  									<table class="table">
						              <thead>
						                <tr>
						                  <th>Choice</th>
						                  <th>File Name</th>
						                  <th>Time</th>
						                </tr>
						              </thead>
						              <tbody>
							{% for key ,value  in file_dict.items %}
								  <tr>
							          <th><input name = "checkbox" class="uniform_on" type="checkbox" id="optionsCheckbox"  value="{{key}}"></th>
						                  <td><B><p  style="font-size:15px"><font color="#00dd00">{{key}}</font></p></B></td>
						                  <td>{{value}}</td>
						                </tr>
							{% endfor %}
						              </tbody>
						            </table>


                        </div>-->
                    </div>

<form action="#" id="form_sample_1" class="form-horizontal">                <!--/span-->
            <fieldset>
<!--
<div class="control-group">
 <label class="control-label">Target Host<span class="required">*</span></label>
<div class="controls">
{% for host in hosts %}
<a name = 'host' value="{{host}}"  class="help-block" >{{host}}</a>
{% endfor %}
</div>
</div>
-->                                                        <div class="control-group">
                                                                <label class="control-label">Command<span class="required">*</span></label>
                                                                <div class="controls">
                                                                        <input type="text" id="cmd"  name="cmd" data-required="1" class="span6 m-wrap"/>
									<span class="help-block">The command you want to exec in system !!! </span>
                                                                </div>
                                                        </div>
<br>


                            <div class="form-actions">
					  <a id = "btn1"  onclick="chk1()"  class="btn btn-primary ">Execute</a>
					  <a id = "btn_cancel"  class="btn tooltip-bottom ">Cancel</a>
                                       </div>

</fieldset>
</form>
<style>
.c_div{ background: #000 ;color:#00EE00;overflow:auto;height:370px;MARGIN-RIGHT: auto; MARGIN-LEFT: auto;border:1px solid #F00;font-size:20px;}

</style>
<div class="c_div" id="cmdata">
</div>
<!--
<li><a href="#"  id = "action1" onclick="chk1()"  value="action1">action1</a></li>-->
        </div>

       </div>


        <script src="{% static 'vendors/jquery-1.9.1.js' %}"></script>
        <script src="{% static 'bootstrap/js/bootstrap.min.js' %}"></script>
        <script src="{% static 'vendors/datatables/js/jquery.dataTables.min.js' %}"></script>


        <script src="{% static 'assets/scripts.js' %}"></script>
        <script src="{% static 'assets/DT_bootstrap.js' %}"></script>







<script "text/javascript">


function chk1(){
var array2=new Array()
array2.push("{{hosts}}")

var text=$("#cmd").val();
array2.push(text)

//alert(array2)


$.post('/admin/execmd/rescmd/',
{
'arraydata':JSON.stringify(array2)
},

function(data){
var d=dialog({
	title:'欢迎',
	content:'命令执行完毕！'
});
d.show();

//alert(typeof data);
//data=data.replace("{","");
//data=data.replace("}","");
//data=data.split(":")[1]
//data=data.replace("u'","");
//data=data.replace("'","");
data=data.replace(/u'|{|}|\\n|,/g,"<br>");
data=data.replace(/'/g,"");
data=data.replace(/\[|\]/g,"");
data=data.replace(/ /g,"&emsp;");
data=data.replace(/\\t/g,"&emsp;");
//data=data.replace(/\\n/g,"<br>");
//var json = eval('(' + data + ')');
$(document).ready(function(){
    $("#cmdata").html(data);

});



});

}

$("#btn_cancel").click(function(){  
                window.close();
            });

</script>


</div>




    </body>

</html>
